import time

from flask import render_template, request

from application.views.api.callback import callback
from application.views.backe_data_reload import back
from application.views.course import course_blue
from application.views.news import news_blue
from application.views.index import index_blue
from application.views.tcourse import tcourse_blue
from application.views.ws import socket
from create_app import flask_obj
from application.views.user import user_blue
from flask_socketio import join_room, emit
from flask_login import login_required

app = flask_obj.app

app.register_blueprint(user_blue, url_prefix='/user')
app.register_blueprint(back, url_prefix='/back')
app.register_blueprint(callback, url_prefix='/callback')
app.register_blueprint(course_blue, url_prefix='/course')
app.register_blueprint(tcourse_blue, url_prefix='/tcourse')
app.register_blueprint(news_blue, url_prefix='/news')
app.register_blueprint(index_blue, url_prefix='/index')


@app.route('/', methods=['get'])
def index():
    return render_template('ws_index.html', async_mode='123')


@app.route('/player', methods=['GET'])
def Film_Play():
    return render_template('player.html', movie={'file': 'vip.mp4', 'title': '???'})


if __name__ == '__main__':
    print(app.url_map)
    # app.run(host='0.0.0.0', port=8000, threaded=True)
    socket.run(app, host='0.0.0.0', port=8000, debug=False)

# flask-socketio==5.3.3
# eventlet==0.33.3
